package com.lzp.wechat.controller;

import com.lzp.wechat.entity.WeiXinBaseResponse;
import com.lzp.wechat.entity.templateMessage.IndustryRequest;
import com.lzp.wechat.entity.templateMessage.IndustryResponse;
import com.lzp.wechat.entity.templateMessage.TemplateMessageRequest;
import com.lzp.wechat.entity.templateMessage.TemplateMessageResponse;
import com.lzp.wechat.service.TemplateMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "模板消息接口")
public class TemplateMessageController {

    @Autowired
    private TemplateMessageService templateMessageService;

    @PostMapping("/setIndustry")
    @ApiOperation(value = "设置所属行业", notes = "需要选择公众账号服务所处的2个行业，每月可更改1次所选行业")
    @ApiImplicitParam(paramType = "body", name = "industryRequest", value = "所属行业请求实体", required = true, dataType = "String")
    public WeiXinBaseResponse setIndustry(@RequestBody IndustryRequest industryRequest) {
        return templateMessageService.setIndustry(industryRequest);
    }

    @GetMapping("/getIndustry")
    @ApiOperation(value = "获取设置的行业信息", notes = "获取设置的行业信息")
    public IndustryResponse getIndustry() {
        return templateMessageService.getIndustry();
    }

    @PostMapping("/sendTemplateMessage")
    @ApiOperation(value = "发送模板消息", notes = "发送模板消息")
    @ApiImplicitParam(paramType = "body", name = "templateMessageRequest", value = "模板消息请求实体", required = true, dataType = "String")
    public TemplateMessageResponse sendTemplateMessage(@RequestBody TemplateMessageRequest templateMessageRequest) {
        return templateMessageService.sendTemplateMessage(templateMessageRequest);
    }

}
